//
//  FMarked.swift
//  xzseller
//
//  Created by zhuxietong on 2021/2/4.
//

import Foundation
open class FMarked:FField{
    public let selectBt = ASButtonNode()
    open override func addLayoutRules() {
        selectBt.ui.nimage(UIImage(named: "icon_select_n")?.rt_tintedImage(with: ._weak)).simage(UIImage(named: "icon_select_s")?.rt_tintedImage(with: ._tint))
        selectBt.imageNode.contentMode = .scaleAspectFit
        selectBt.addTarget(self, action: #selector(toggle), forControlEvents: .touchUpInside)
    }
    
    @objc open func toggle(){
        selectBt.isSelected = !selectBt.isSelected
        update(value: selectBt.isSelected.tag, edit: .select)
    }
    open override func didLoadProps() {
        super.didLoadProps()
        let v = "\(value)"
        selectBt.isSelected = v == "1"
    }
    
    open override func specGetter() -> _Spec {

        return .inset([], [14,13,14,16], child: .stack(["h|6",&-.center], childs: [
            selectBt["20",20],
            lableNode.Spec
        ]))
    }
}
 
open class FRadioMarked:FMarked{
//    open var _lable:NSAttributedString{
//        get{
//            if props.required{
//                return label.ui.font(font: labelStyle.font).color(color: labelStyle.color).astring + " *".ui.bfont14.color(color: .systemRed).astring
//            }
//            
//            return label.ui.font(font: labelStyle.font).color(color: labelStyle.color).astring
//        }
//    }
    open override func specGetter() -> _Spec {

        return .inset([], [14,-2,14,16], child: .stack(["h|6",&-.center], childs: [
            selectBt["20",20],
            lableNode.Spec
        ]))
    }
}
